//
//  LBCommonMacro.h
//  LBCategoryLibrary
//
//  Created by smufs on 2017/3/8.
//  Copyright © 2017年 李冰. All rights reserved.
//

#ifndef LBCommonMacro_h
#define LBCommonMacro_h

#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, ChosePhotoType) {
    ChosePhotoTypeAlbum,
    ChosePhotoTypeCamera
};


#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"%s:%d  \t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
//NSLog(...) NSLog(__VA_ARGS__);
//#define LOG_METHOD NSLog(@"%s", __func__);
#else
#define NSLog(...) ;
//#define LOG_METHOD ;
#endif

// ================== 宏定义变量名 ===================
// int varName(a) = 2 -> int vara = 2
#define VarName(n) var##n

// ================== 将变量名转对应的字符串 ===========
// int test = 1;
// varNameToString(test) -> test
// 可见系统定义的宏NSDictionaryOfVariableBindings(...)
#define VarNameToString(...) @"" # __VA_ARGS__

// =============== 日志 ===============
#ifdef DEBUG
#define LBLog(FORMAT, ...) fprintf(stderr,"%s:%d  \t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
//NSLog(...) NSLog(__VA_ARGS__);
//#define LOG_METHOD NSLog(@"%s", __func__);

#define XCODE_COLORS_ESCAPE_MAC @"\033["
#define XCODE_COLORS_ESCAPE_IOS @"\xC2\xA0["
#define XCODE_COLORS_ESCAPE  XCODE_COLORS_ESCAPE_MAC
#define XCODE_COLORS_RESET_FG  XCODE_COLORS_ESCAPE @"fg;" // Clear any foreground color
#define XCODE_COLORS_RESET_BG  XCODE_COLORS_ESCAPE @"bg;" // Clear any background color
#define XCODE_COLORS_RESET     XCODE_COLORS_ESCAPE @";"   // Clear any foreground or background color
#define LLogBlue(frmt, ...) NSLog((@"%s [Line: %d] ----- > : " XCODE_COLORS_ESCAPE @"fg0,150,255;" frmt XCODE_COLORS_RESET),[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String],__LINE__, ##__VA_ARGS__)

#else
#define LBLog(...) ;
#define LLogBlue(frmt, ...)
//#define LOG_METHOD ;
#endif

// ===================== 弱指针 =====================
#define LBWeakSelf(type) __weak typeof(type) weak##type = type
#define WEAKSELF typeof(self) __weak weakSelf = self;
// ===================== 链接字符串 =================== LBConnectString(我是字符串)
#define LBConnectString(str) [NSString stringWithFormat:@"%@", @#str]

// ===================== 系统相关 =====================
#define APP_DELEGATE() ((AppDelegate*)[[UIApplication sharedApplication] delegate])
#define IS_IPHONE_5 ([[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_IOS_7 (([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7.0) ? YES : NO)
#define IsIOS7 ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue] >= 7)
#define IsIOS8 ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue] >= 8.0)
#define IsIOS9 (([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue] >= 9.0) && [[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]<10.0)
#define IsIOS10 ([[[UIDevice currentDevice] systemVersion] compare:@"10" options:NSNumericSearch] != NSOrderedAscending)

// ==================== App Version ====================
#define AppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

#define AppBuildVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]

// ===================== 尺寸相关 =====================
/** 屏幕尺寸*/
#define lbScreenSize [UIScreen mainScreen].bounds.size

#define lbScreenWidth lbScreenSize.width
#define lbScreenHeight lbScreenSize.height

#define lbKeyWindow [UIApplication sharedApplication].keyWindow

#define lbFont(fSize) [UIFont systemFontOfSize:(fSize)]
#define adaptationFont(fSize) [UIFont systemFontOfSize:AdaptationRatioW(fSize)]

// 不同手机适配比例
#define AdaptationRatioH(h) (lbScreenSize.height / 667)* h
#define AdaptationRatioW(w) (lbScreenSize.width / 375)* w
// 不同手机适配比例
#define AdaptationRatio(w) (lbScreenWidth / 375.0f)* w

/** 状态栏高度*/
#define  lbStatusBarHeight 20.f

/** 导航栏高度*/
#define  lbNavigationBarHeight 44.f

/** 标签栏高度*/
#define  lbTabbarHeight 49.f

// ===================== 设备App相关===================
// app名称
#define App_Name [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
// app版本
#define App_Version [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
// app build版本
#define App_Build [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]

//手机序列号
#define Device_UUID [[UIDevice currentDevice].identifierForVendor UUIDString]
//手机别名 my iPhone
#define Device_PhoneName [[UIDevice currentDevice] name]
//设备名称 iOS
#define Device_SystemName [[UIDevice currentDevice] systemName]
//手机系统版本 iOS 10.0
#define Device_SystemVersion [[UIDevice currentDevice] systemVersion]
//手机型号 iPhone iPod
#define Device_PlatformModel [[UIDevice currentDevice] model]
//地方型号  （国际化区域名称）
#define Device_LocalModel [[UIDevice currentDevice] localizedModel]

/** documentPath */
#define DocumentPath  NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject

/** cachesPath */
#define CachesPath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)lastObject]

/** librabyPath */
#define LibraryPath [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)lastObject]

/** tmpPath */
#define TmpPath NSTemporaryDirectory()

// 角度弧度互转 M_PI = 180°
// 弧度 -> 角度
#define RADIANS_TO_DEGREES(x) ((x)/M_PI*180.0)
// 角度 -> 弧度
#define DEGREES_TO_RADIANS(x) ((x)/180.0*M_PI)

// API host address
// api访问地址
//#define kBaseUrl @"https://panda.dengcesuo.com/api.php"
#define kBaseUrl @"https://www.wm135.com/api.php"

#define kAccessCode @"ce61649168c4550c2f7acab92354dc6e"
#define kClientApiVersion @"v1"
#define kShopsApiVersion @"s1"
#define kHorsrmanApiVersion @"r1"
// 测试地址 https://panda.dengcesuo.com/hello_api

#define kBaiDuAppKey @"xe2xWsUAdxr8lAY7GaAOHNk3sGdOiXpm"
#define kJiGuangAppKey @"44a5c957f52fe87f5e1d8013"
#define kJiGuangSecret @"fb83f90155c56164ae39c8f2"

// 分页每页数据
#define kPageNumber 10

// ===================== 颜色相关 =====================
/** 颜色*/
#define Color(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]

/** tabBar填充颜色*/
#define TabBarTintColor [UIColor colorWithHexString:@"#eeeeee"]

/** 主要颜色颜色*/
#define kMainColor [UIColor colorWithHexString:@"#13b5ea"]
#define kOrangeColor [UIColor colorWithHexString:@"#ff9f08"]
#define kPinkColor [UIColor colorWithHexString:@"#fa878c"]

/** 背景颜色*/
#define kBgColor [UIColor colorWithHexString:@"#f5f5f5"]

/** 分割线颜色*/
#define kLineColor [UIColor colorWithHexString:@"#dbdbdb"]

/** 底部分割线颜色*/
//#define kBottomLineColor [UIColor colorWithHexString:@"#d8d8d8"]

/** 常用颜色*/
#define kBlackColor [UIColor colorWithHexString:@"#323232"]
#define kWhiteColor [UIColor colorWithHexString:@"#ffffff"]
#define kBtnWhiteColor [UIColor colorWithHexString:@"#ffc8c8"]
#define kDarkGrayColor [UIColor colorWithHexString:@"#646464"]
#define kGrayColor [UIColor colorWithHexString:@"#969696"]
#define kLightGrayColor [UIColor colorWithHexString:@"#e8e8e8"]
#define kBlueColor [UIColor colorWithHexString:@"#009de6"]
#define kRandomColor [UIColor colorWithRed:arc4random() % 256 / 255.0f green:arc4random() % 256 / 255.0f blue:arc4random() % 256 / 255.0f alpha:1]

#define COMMON_MARGIN_TEN 10
#define COMMON_MARGIN_FIFTEEN 15
#define FOURTEEN_LABEL_HEIGHT (14 + COMMON_MARGIN_FIFTEEN)

// 商品信息列高度
#define GOODS_ITEM_HEIGHT 55

// 电话
#define PANDATAKEAWAY_PHONE @"666666"

// 占位图
#define PLACE_HOLDER [UIImage imageNamed:@"icon"]

// 选择的城市和id key
#define SELECT_CITY_NAME_KEY @"SELECT_CITY_KEY"
#define SELECT_CITY_ID_KEY @"SELECT_CITY_ID_KEY"

// 用户模型 主键
#define USER_MODEL_KEY @"USER_MODEL_KEY"

// 历史搜索
#define USER_SEARCH_HISTORY @"USER_SEARCH_HISTORY"

#endif /* LBCommonMacro_h */
